<% if can? :create, Topic %>

        <div class="panel panel-default clearfix">
            <div class="panel-body">
                <div class="btn-group pull-left">
                    <% if !select_node.blank? %>
                        <%= link_to(t("topics.start_a_new_topic_button"), new_topic_path(node: select_node.id), class: "btn btn-primary" )%>
                    <% else %>
                        <%= link_to(t("topics.start_a_new_topic_button"), new_topic_path, class: "btn btn-primary" )%>
                    <% end %>
                    <button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <% cache(["sidebar_new_topic_box",SiteConfig.new_topic_dropdown_node_ids]) do %>
                        <% Node.new_topic_dropdowns.each do |node| %>
                            <li>
                                <%= link_to(node.name, new_topic_path(node: node.id)) %>
                            </li>
                        <% end %>
                        <% end %>
                    </ul>
                </div>

                <%= link_to(sanitize("<span class='icon icons-rss'></span> RSS"), feed_topics_url, title: t("topics.subscribe_with_rss", name: Setting.app_name), class: "pull-right feed-button btn btn-default", target: "_blank") %>
            </div>
        </div>

<% else %>
    <% if current_user && !current_user.avatar? %>
    <div class="panel panel-default clearfix">
        <div class="panel-body">
            <p><%= t('topics.have_no_avatar')%></p>
            <%= link_to t('common.upload'), edit_user_registration_path, class: 'btn btn-warning btn-block' %>
        </div>
    </div>
    <% end %>
<% end %>

<% if current_user && current_user.newbie? %>
    <div class="panel panel-default">
        <div class="panel-heading">新手必读</div>
        <div class="panel-body">
            <%= raw SiteConfig.newbie_notices %>
        </div>
    </div>
<% end %>

<%= render "topics/sidebar_box_tips" %>

<%= raw SiteConfig.topic_index_sidebar_html %>

<% cache(["sidebar_statistics",Time.now.strftime("%Y-%m-%d %H")]) do %>
    <div class="panel panel-default">
        <div class="panel-heading"><%= t("common.statics")%></div>
        <ul class="list-group">
            <li class="list-group-item">社区会员: <%= User.unscoped.count %> 人</li>
            <li class="list-group-item">帖子数: <%= Topic.unscoped.count %> 个</li>
            <li class="list-group-item">回帖数: <%= Reply.unscoped.count %> 条</li>
        </ul>
    </div>
<% end %>


